<?php

declare (strict_types=1);

namespace addons\Detection\driver;

use think\facade\View;
use think\Request;

class Detection
{
    public function handle(Request $request, \Closure $next)
    {
        if (strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false) {
            $path = app()->getRootPath() . '/addons/Detection/view/';
            $res = View::fetch($path . 'index.html', [
                'path' => base64_encode(file_get_contents($path . 'images/tips.png'))
            ]);
            exit($res);
        }
        return $next($request);
    }
}